package com.atguigu.springcloud.consumer;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class TestController {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${server.port}")
    private String serverPort;

    @Value("${service-url.nacos-payment-service}")
    private String paymentServiceURL;

    @GetMapping(value = "/consumer_to/{str}")
    public String rest(@PathVariable String str) {
        String url = paymentServiceURL + "/payment_re/" + str;
        System.out.println("URL:" + url);
        return restTemplate.getForObject(url, String.class);
    }

    @GetMapping(value = "/consumer_re/{str}")
    public String feign(@PathVariable String str) {
        return "payment-->consumer  : return consumer-server(consumer_re) " + str + " Port : " + serverPort ;
    }

}